package com.miku.blog.controller;

import com.miku.blog.annotation.SystemLog;
import com.miku.blog.domain.WebsitePage;
import com.miku.blog.domain.pojo.ResponseResult;
import com.miku.blog.service.WebsitePageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author shkstart
 * @create ${}YEAR-06-14 4:46
 */
@Api(tags = "后台管理系统{博客页面配置}")
@RequestMapping("/admin")
@RestController
public class WebSitePageController {

    @Autowired
    private WebsitePageService websitePageService;


    @SystemLog(notes = "获取博客页面列表{后台管理系统}")
    @ApiOperation(value = "获取博客页面列表接口")
    @GetMapping("/pages")
    public ResponseResult getPages(){
        return websitePageService.getPages();
    }


    @SystemLog(notes = "更新博客页面{后台管理系统}")
    @ApiOperation(value = "更新博客页面接口", notes = "更新博客页面数据")
    @PostMapping("/pages")
    public ResponseResult updatePage(@RequestBody WebsitePage websitePage){
        return websitePageService.updatePage(websitePage);
    }


    @SystemLog(notes = "删除博客页面数据{后台管理系统}")
    @ApiOperation(value = "删除博客页面数据接口", notes = "根据页面ID 删除博客页面数据")
    @DeleteMapping("/pages/{pageId}")
    public ResponseResult delPage(@PathVariable("pageId") Integer pageId){
        return websitePageService.delPage(pageId);
    }

}
